﻿using AppTemplate.UI.Framework;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using System.Windows.Media;

namespace AppTemplate.UI.Converters
{
    [ValueConversion(typeof(ColorType), typeof(SolidColorBrush))]
    public class ColorTypeConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ColorType ct = (ColorType)value;
            string colorResourceKey = null;
            switch (ct)
            {
                case ColorType.Success:
                    colorResourceKey = "color-success";
                    break;
                case ColorType.Primary:
                    colorResourceKey = "color-primary";
                    break;
                case ColorType.Danger:
                    colorResourceKey = "color-danger";
                    break;
                case ColorType.Warning:
                    colorResourceKey = "color-warning";
                    break;
                case ColorType.Info:
                default:
                    colorResourceKey = "color-info";
                    break;
            }
            var obj = Application.Current.FindResource(colorResourceKey);
            var res = obj as SolidColorBrush;
            return res;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
